import ScreenFit from "../ScreenFit";
import EventManager from "../EventManager";

const { ccclass, property } = cc._decorator;

@ccclass
export default class FitPosition extends cc.Component {

    onLoad() {
        if (ScreenFit.isFitted) {
            this.fitPos();
        } else {
            EventManager.addEvent(ScreenFit.Event_OnFitted, this.fitPos, this);
        }
    }

    private fitPos() {
        this.node.x = ScreenFit.screenSize.width * this.node.x / 1334;
        this.node.y = ScreenFit.screenSize.height * this.node.y / 750;
    }

}
